<?php
//+-----------------
//|应用程序初始化
//|加载必要的数据
//+----------------
class App{	
	protected $controller;
	protected $model;
	/**
	 * 初始化环境变量
	 *
	 */
	static public function Run(){		
		$app=new App();	
		$app->AutoLoadFun();	
		$app->NavUrl();
		
	}
	/**
	 * 页面导航模型
	 * Enter description here ...
	 */	
	private function NavUrl(){		
		if (!empty($_SERVER['PATH_INFO'])){				   
			  $parray=$_SERVER['PATH_INFO'];		
		      $url=$_SERVER['REQUEST_URI'];			
			  $str=explode("/",trim($parray,"\/"));              
			  $controller=ucfirst($str[0])."Controller";			  
			  $model=ucfirst($str[1]);
			
		}else {			
			$controller=isset($_GET["a"])?ucfirst($_GET["a"])."Controller":"IndexController";
            $model=isset($_GET["m"])?ucfirst($_GET["m"]):"Index";			
		}		
		$this->controller=$controller;
		$this->model=$model;		
        $controllerClass=new $controller();        
        url_parse();
        $controllerClass->$model();        
	}
	//自动载入自定义函数库
	private function AutoLoadFun(){
		if (file_exists(AppDir."/Common/function.php")){
			include_once AppDir."/Common/function.php";
		}
	}
	
}


?>